const ItemGroupBy = (data = [], field: string) => {
  let result = {
    default: [],
  };
  data.forEach((item) => {
    let group = item[field];
    if (group) {
      if (!result[group]) {
        // @ts-ignore
        result[group] = [];
      }
      // @ts-ignore
      result[group].push(item);
    } else {
      result["default"].push(item);
    }
  });
  return result;
};

const ObjectToArray = (object: object) => {
  return Object.keys(object)
    .map((key) => {
      // @ts-ignore
      return object[key];
    })
    .filter((item) => item.length);
};

export { ItemGroupBy, ObjectToArray };
